﻿using Pay.Core;
using Pay.DTO;
using Pay.IService;
using Pay.TO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Pay.Web.Areas.Admin.Controllers
{
    [RouteArea("admin")]
    [RoutePrefix("userFeedBack")]
    public class UserFeedBackController : AdminController
    {
        private IUserFeedBackService _iUserFeedBackService;

        public UserFeedBackController(IUserFeedBackService iUserFeedBackService)
        {
            _iUserFeedBackService = iUserFeedBackService;
        }

        public ActionResult Index()
        {
            return View();
        }

        public JsonResult Gets(UserFeedBackQuery query)
        {
            var model = _iUserFeedBackService.GetUserFeedBacks(query);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        public JsonResult Get(long id)
        {
            var model = _iUserFeedBackService.GetUserFeedBack(id);
            return Json(ResultToJson.Json(model), JsonRequestBehavior.AllowGet);
        }

        [ValidateInput(false)]
        public JsonResult ReplyUserFeedBack(user_feedback_dto dto) {
            var result = _iUserFeedBackService.ReplyUserFeedBack(dto, currentUser.user_id);
            return Json(ResultToJson.Json(result ? " 保存成功" : "未做任何修改", result), JsonRequestBehavior.AllowGet);

        }

    }
}